<?php

declare(strict_types=1);

namespace SixShop\Wangdian\Services;

use SixShop\Wangdian\Response\ApiResponse;

/**
 * Basic service for shops, warehouses, logistics, etc.
 */
class BasicService extends BaseService
{
    /**
     * Query shop information
     */
    public function queryShop(array $params = []): ApiResponse
    {
        return $this->call('shop.php', $params);
    }

    /**
     * Query warehouse information
     */
    public function queryWarehouse(?string $warehouseNo = null): ApiResponse
    {
        $params = [];
        if ($warehouseNo !== null) {
            $params['warehouse_no'] = $warehouseNo;
        }

        return $this->call('warehouse_query.php', $params);
    }

    /**
     * Query logistics providers
     */
    public function queryLogistics(): ApiResponse
    {
        return $this->call('logistics.php');
    }

    /**
     * Query purchase providers
     */
    public function queryPurchaseProvider(?string $providerNo = null): ApiResponse
    {
        $params = [];
        if ($providerNo !== null) {
            $params['provider_no'] = $providerNo;
        }

        return $this->call('purchase_provider_query.php', $params);
    }

    /**
     * Create purchase provider
     */
    public function createPurchaseProvider(array $providerData): ApiResponse
    {
        $this->validateRequired($providerData, ['provider_name']);

        return $this->call('purchase_provider_create.php', 
            $this->filterParams($providerData)
        );
    }
}